package AggregationMethod;

import java.util.ArrayList;

import Definitions.GraphClass;
import Definitions.NodeClass;
import Global.ConstantVariable;
import Global.GlobalClass;
import Read.ReaderClass;
import Sampling.SamplingAbstractClass;
import Sampling.SamplingFactory;
import Sampling.SamplingTests;

public class AggregationTests 
{

	public static void Test(String aggregationMethodName,  SamplingAbstractClass currentSampling) throws Exception
	{
		GraphClass g  = new GraphClass(); 
		GlobalClass global  = new GlobalClass();
		Read(ConstantVariable.DataSet_Constants.CORA, g, global);
		
		SamplingFactory samplingFactory = new SamplingFactory();
		
		SamplingAbstractClass sampling=samplingFactory.createSampling(SamplingTests.createDummyParametresForSampling(ConstantVariable.Sampling_Constants.SNOWBALL_SAMPLING_METHOD), g, global);
		
		System.out.println(sampling.getName());
	
		sampling.generateSampling(g,0);
		
		((SamplingAbstractClass)sampling).setClassRatiosWithTrain(g);
		
		AggregationMethodFactory factory = new AggregationMethodFactory();
				
		AggregationMethodInterface aggregationMethod= factory.createAggregationMethod(aggregationMethodName, sampling);
		
		System.out.println("Aggregation Method Test : "+ aggregationMethodName );
		
		
		for(int i=0 ; i<5 ;i++)
		{
			ArrayList <NodeClass> neighbours = currentSampling.findNeighbours(g.getDataSet().get(i), ConstantVariable.Sampling_Constants.NODE_IS_IN_TEST_SET_FOR_THE_FOLD, 0, 1);

			ArrayList <Double> vector =aggregationMethod.getAggregatedNeighbourVector(neighbours);
			
			for(double f: vector)
			{
				System.out.print(f +"  ");
			}
			
			System.out.println();
		}
	}

	public static void Read(int DataSet, GraphClass g, GlobalClass global)
	{
			System.out.println(" Start of Reading ");
			String content;
			String cites;
			ReaderClass r = new ReaderClass();
			String splitchar;
			if(DataSet==1)
			{
				System.out.println("Citeseer");
				content = "citeseer.content";
				cites = "citeseer.cites";
				splitchar="	";
				r.Read(content, cites, splitchar, g, global);
				
				
			}
			else if(DataSet==2)
			{
				System.out.println("Cora");
				content = "cora.content";
				cites   = "cora.cites";
				splitchar="	";
				r.Read(content, cites, splitchar, g, global);
				System.out.println("   "+g.getDataSet().size());
				System.out.println("   "+g.getDataSet().get(0).getContent(0).size());
			}
	}
}
